package abc.com.abc.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import java.util.Timer;
import java.util.TimerTask;

import abc.com.abc.R;

public class SplashActivity extends Activity {
    private TextView tv_version;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        init();
    }

    private void init() {
        tv_version = findViewById(R.id.tv_version);
        try {
            PackageInfo info = getPackageManager().getPackageInfo(getPackageName(),0);
            tv_version.setText("版本号V"+info.versionName);

        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            tv_version.setText("V");
        }
        Log.i("111", "init: info+info.versionName");
    //延迟3秒
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
             Intent intent = new Intent(SplashActivity.this,MainActivity.class);
             startActivity(intent);
             SplashActivity.this.finish();
            }
        };
        timer.schedule(task,3000);//设置TASK停留3秒



    }
}
